package com.csw.compose.ui.components

import androidx.compose.foundation.background
import androidx.compose.foundation.border
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.shape.CircleShape
import androidx.compose.material3.Card
import androidx.compose.material3.LocalContentColor
import androidx.compose.material3.LocalTextStyle
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp

/**
 * 无需列表
 */
@Composable
fun UlItem(content: String) {
    Card(modifier = Modifier.fillMaxWidth()) {
        Row(
            modifier = Modifier.padding(10.dp),
            verticalAlignment = Alignment.CenterVertically
        ) {
            Box(
                modifier = Modifier
                    .size(12.dp)
                    .border(12.dp, LocalContentColor.current, CircleShape)
            )
            NormalSpacer()
            Text(content)
        }
    }
}

/**
 * 有序列表
 */
@Composable
fun OlItem(index: Int,content: String) {
    Card(modifier = Modifier.fillMaxWidth()) {
        Row(
            modifier = Modifier.padding(10.dp),
            verticalAlignment = Alignment.CenterVertically
        ) {
            Text("${index}.")
            NormalSpacer()
            Text(content)
        }
    }
}

@Preview
@Composable
fun ListItemPreview() {
    Column {
        repeat(2){
            UlItem("无序列表")
            PreviewSpacer()
        }
        repeat(3){
            OlItem(it+1,"有序列表")
            PreviewSpacer()
        }
    }
}